<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 准备一个空对象
        var obj1 = new Object();
        // 增加属性和方法
        obj1.name = 'xxds';
        obj1.age = 10;
        obj1.show = function() {
            console.log('下楼做核酸！');
        }

        var obj2 = {
            name: 'AAA',
            age: '18',
            show: function() {
                console.log('好好学习！');
            }
        }

        // Object.assign(objA, objB) objA吸收了objB objA中就有objB的属性和方法


        function fnAssign(obj) {
            var deObj = {
                a: 'A',
                b: 'B',
                c: 'C',
                d: 'D',
            }

            var newObj = Object.assign(deObj, obj)
            console.log(newObj);
        }

        var objX = new Object;
        objX.a = 1;
        objX.b = 2;
        fnAssign(objX)


        // 通过"."运算符 给对象增加属性和方法 最终输出在页面上
        var person = {};
        person.name = 'Ma baoguo';
        person.age = '70';
        person.job = '掌门人';
        person.intro = function() {
            var str = "名字："+person.name+"年龄："+person.age+'职业：'+person.job;
            document.write(str)
        }

        person.intro()
    </script>
</body>
</html>